package com.androidbook;

import java.io.InputStream;
import java.net.URL;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

 class BitmapUtil
 {
    
    public static Bitmap loadFrom(String url, Context context, int defaultDrawable)
    {
        try
        {
            InputStream is = (InputStream) new URL(url).getContent();
            try
            {
                return BitmapFactory.decodeStream(is);
            } finally
            {
                is.close();                    
            }
        } catch (Exception e)
        {
            return BitmapFactory.decodeResource(context.getResources(), defaultDrawable);
        }
    }
 
}
